This page last changed on Oct 15, 2009 by michael.

RSS Data Model

RSS (Really Simple Syndication) is an XML-based document format for the syndication of web content such as weblogs and news headlines to Web sites as well as directly to user agents. Apache Wink supports the RSS 2.0 specification.

(Really Simple Syndication) RSS Data Model Overview

Apache Wink provides an RSS data model for consuming and producing RSS Feeds (application/xml). All of the model classes are located under org.apache.wink.common.model.rss package.

RSS Feed Support

The following table shows the RSS Feed data models and the representations in which it can be serialized and de-serialized.

  Supported Media Types Data Model Provider registration
Read Yes application/xml org.apache.wink
.common.model
.rss.RssFeed
Not required. Registered by default
Write Yes application/xml org.apache
.wink.common
.model.rss
.RssFeed
Not required. Registered by default

Examples

The following code example demonstrates reading and writing of RSS Feeds.

Producing RSS Feed

The following code example demonstrates the creation of an RSS Feed.

    @GET
    @Produces(MediaType.APPLICATION_XML)
    public RssFeed getFeed() {
        RssFeed rss = new RssFeed();

        RssChannel channel = new RssChannel();
        channel.setTitle("Liftoff News");
        channel.setLink("http://liftoff.msfc.nasa.gov");
        channel.setDescription("Liftoff to Space Exploration.");
        channel.setPubDate(new Date().toString());

        RssItem item = new RssItem();
        item.setTitle("Star City");
        item.setLink("http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp");
        item.setDescription("How do Americans get ready to work with Russians aboard the International Space Station?");
        channel.getItems().add(item);

        ...

        rss.setChannel(channel);
        return rss;
    }
}

Consuming RSS Feed

The following code example demonstrates the consumption of an RSS Feed.

    @POST
    @Consumes(MediaType.APPLICATION_XML)
    public void setFeed(RssFeed feed) {
        ...

        return;
    }
Document generated by Confluence on Nov 11, 2009 06:57